package com.yicong.ants.activity

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.view.View
import android.webkit.WebView
import android.widget.TextView
import com.blankj.utilcode.util.BarUtils
import com.yicong.ants.R

class PureWebViewActivity : Activity() {
    private val webView: WebView by lazy {
        findViewById(R.id.webView)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.pure_webview_activity)
        BarUtils.setStatusBarColor(this, Color.WHITE)
        findViewById<TextView>(R.id.titleTv).text = intent.getStringExtra("title") ?: ""
        findViewById<View>(R.id.backBtn).setOnClickListener {
            finish()
        }
        webView.loadUrl(intent.getStringExtra("url") ?: "")
    }

    companion object {
        fun start(context: Context, title: String, url: String) {
            val intent = Intent(context, PureWebViewActivity::class.java)
            intent.putExtra("url", url)
            intent.putExtra("title", title)
            context.startActivity(intent)
        }
    }
}